project(carpool)


#-----------------------------------------------------------------------------
# CMake administrivia
cmake_minimum_required( VERSION 2.8 )
if ( COMMAND cmake_policy )
  cmake_policy( SET CMP0003 NEW )
endif( COMMAND cmake_policy )

#option( BUILD_SHARED_LIBS "Set to ON to build shared libraries" OFF )
#set( LIBRARY_OUTPUT_PATH    bin CACHE PATH "Path to libraries"   FORCE )

set( EXECUTABLE_OUTPUT_PATH bin CACHE PATH "Path to executables" FORCE )
set( UPDATE_TYPE "svn" )
set( CMAKE_COLOR_MAKEFILE ON CACHE BOOL "Color" FORCE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_FILESYSTEM_VERSION=3" )


option( ALLOW_CAMBIO_WINE_FILE_OPEN "Use the WINE based cambio_wine utility to convert file formats to a format that can be natively opened (you probably dont want this in)" OFF )
option( REQUIRE_USER_AUTH "Build the logon auithentication mechanism" ON )

option( BUILD_UI_SERVER "Build the portion of the app meant to serve the GUI" ON )
option( BUILD_UPLOAD_SERVER "Build the portion of the app meant catch the files form the detector" ON )
option( BUILD_GADRAS_ANALYSIS_SERVER "Build the portion of meant interact with GADRAS to analyze the spectrums" ON )

IF(NOT CMAKE_BUILD_TYPE)
    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
        FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)



#-----------------------------------------------------------------------------

SET(LIBRARYNAME carpool)
SET(EXECNAME carpool.wt)

SET(EXECUTABLE_OUTPUT_PATH ".")
include(cmake/FindWt.cmake)

INCLUDE(cmake/WtFindZlib.txt)

SET( Boost_ADDITIONAL_VERSIONS "1.41" "1.42" "1.43" "1.44.0" "1.44" "1.45" "1.46" "1.47" "1.48" "1.49" )

INCLUDE(cmake/WtFindBoost-cmake.txt)
IF(NOT BOOST_WT_FOUND)
  SET(ERR
     "Could not find a boost installation in " ${BOOST_PREFIX} ".\n\n"
      "There are two methods in Wt to find boost:")
  MESSAGE(FATAL_ERROR ${ERR})
ENDIF(NOT BOOST_WT_FOUND)



set( sources
)


set( headers
)



#We should have figured out all the header and source files we need by here, so
#  lets add the executable to the build
add_executable( ${EXECNAME} main.cpp ${sources} ${headers} )


INCLUDE_DIRECTORIES(
    ${Wt_INCLUDE_DIR}
    ${Boost_INCLUDE_DIR}
    ${CMAKE_BINARY_DIR}
    .
    ..
)



target_link_libraries (
    ${EXECNAME}
    ${Wt_LIBRARIES}
    ${Boost_LIBRARIES}
    ${Boost_SYSTEM_LIBRARY}
    ${Boost_REGEX_LIBRARY}
    ${Boost_THREAD_LIBRARY}
    ${Boost_FILESYSTEM_LIBRARY}
    ${Boost_DATE_TIME_LIBRARY}
    ${Boost_SIGNALS_LIBRARY}
    ${Boost_SERIALIZATION_LIBRARY}
)



foreach(_file ${OTHER_FILES})
  configure_file(
    ${PROJECT_SOURCE_DIR}/${_file}
    ${PROJECT_BINARY_DIR}/${_file}
    COPYONLY
    )
endforeach()



FIND_PATH( WT_RESOURCES_DIRECTORY form.css
        ${Wt_INCLUDE_DIR}/../share/Wt/resources
)




IF(NOT WT_RESOURCES_DIRECTORY)
  MESSAGE("Could not find the Wt resources path to copy into current directory")
ELSE(NOT WT_RESOURCES_DIRECTORY)
  MESSAGE("Using Wt resources from ${WT_RESOURCES_DIRECTORY}")
  file(COPY ${WT_RESOURCES_DIRECTORY}
      DESTINATION ${PROJECT_BINARY_DIR}/
      )
ENDIF(NOT WT_RESOURCES_DIRECTORY)


#SET(SUPPORT_DIRECTORIES
#    local_resources
#)



foreach(_dir ${SUPPORT_DIRECTORIES})
  file(COPY
    ${PROJECT_SOURCE_DIR}/${_dir}
    DESTINATION
    ${PROJECT_BINARY_DIR}/
    )
endforeach()


